/////////////////////////////////////////////////////////////////////////////
// Purpose:     Log handler for the system's default logging mechanisms
// Author:      Jesus Gonzalez
// Modified by:
// Copyright:   (c) 2003-2013 Jesus Gonzalez <jgonzalez@gdr-sistemas.com>
// License:     BSD License
/////////////////////////////////////////////////////////////////////////////

#ifndef _SMARTLIB_SYSLOG_H_
#define _SMARTLIB_SYSLOG_H_

/**
 * \file
 * %Log handler for the system's default logging mechanisms.
 */

#include <SmartLib/Log.h>

///@defgroup log Logging
///@{

/**
 * The SysLog class implements a log handler that uses the system's default
 * logging mechanisms to create log annotations (e.g. syslog in Linux).
 *
 * @see Log
 */
class SysLog : public LogHandler
{
public:
    DECLARE_SMARTPTR(SysLog)

    /**
     * Creates a new SysLog than can be set as the log handler for the application.
     *
     * @param[in] consoleLog If set to \p true, the logs will be displayed in the
     * console in addition to being stored by the system.
     * @return A new SysLog.
     */
    static SysLog::Ptr New(bool consoleLog = false)
    {
        return new SysLog(consoleLog);
    }

    /**
     * Creates a new SysLog then sets it as the log handler for the application.
     *
     * @param[in] consoleLog If set to \p true, the logs will be displayed in the
     * console in addition to being stored by the system.
     */
    static void Setup(bool consoleLog = false);

    virtual bool Process( int prio, const char* category, const char* function, const char* msg );

protected:
    ///@cond
    bool m_consoleLog;
    SysLog(bool consoleLog);
    ///@endcond
};

///@}

#endif // _SMARTLIB_SYSLOG_H_
